package com.pay.ioopos.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SettingHelper extends SQLiteOpenHelper {
    public static final String INIT_KEY = "exampleomKKAj0yYu1p9ILepVtyz3YGJATFB";
    public SettingHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table setting(name varchar(50) primary key, value varchar(500))");
        init(db);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        init(db);
    }

    private void init(SQLiteDatabase db) {
        db.execSQL("insert into setting (name, value) values('mode', '0')");
        db.execSQL("insert into setting (name, value) values('maxAmount', '0.1')");
        db.execSQL("insert into setting (name, value) values('fixAmount', '0.1')");
        db.execSQL("insert into setting (name, value) values('pwd', '000000')");
        db.execSQL("insert into setting (name, value) values('transKey', '" + INIT_KEY + "')");
        db.execSQL("insert into setting (name, value) values('serverUrl', 'https://pay.example.com')");
    }
}
